#!/usr/bin/env python
import sys
import argparse
from res.fm.templating import render_template


def _build_argument_parser():
    description = (
        'Loads the data from each file ("some/path/filename.xxx") in INPUT_FILES '
        'and exposes it as the variable "filename". It then loads the Jinja2 '
        'template TEMPLATE_FILE and dumps the rendered resoult to OUTPUT.'
    )
    parser = argparse.ArgumentParser(description=description)
    parser.add_argument(
        '--output_file',
        required=True,
        help='the output file',
    )
    parser.add_argument(
        '--template_file',
        required=True,
        help='the jinja2 template file',
    )
    parser.add_argument(
        '--input_files',
        nargs='+',
        help='list of json and yaml input files',
    )
    return parser

if __name__ == '__main__':
    arg_parser = _build_argument_parser()
    args = arg_parser.parse_args()

    render_template(
        args.input_files,
        args.template_file,
        args.output_file,
    )
